/*
*Copyright (c) Nikhil Jain.
*Project ICARUS, communications and 
*artificial intelligence.
*/



/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
 */
package javadrone.server.simulation;

//~--- non-JDK imports --------------------------------------------------------

import javadrone.SensoryData;

import javadrone.server.DroneImpl;
import javadrone.server.StateChangeEvent;
import javadrone.server.listeners.StateChangeListener;

import javadrone.statedata.*;

/**
 *
 * @author Nikzzay
 */
public class StateFollower implements StateChangeListener {
    public AerialStateData       aerialState;
    public BootData              bootState;
    public CollisionStateData    collisionState;
    public ErrorData             errorState;
    public NavigationData        navigtionState;
    public VideoCaptureStateData videoState;

    public StateFollower(DroneImpl drone) {
        drone.getCompleteState().addStateChangeListener(this);
    }

    @Override
    public void stateChanged(StateChangeEvent sce) {
        Object sd = ((StateData) (sce.getCurrentState())).getData();

        if (sd instanceof AerialStateData) {
            this.aerialState = (AerialStateData) sd;
        } else if (sd instanceof BootData) {
            this.bootState = (BootData) sd;
        } else if (sd instanceof CollisionStateData) {
            this.collisionState = (CollisionStateData) sd;
        } else if (sd instanceof ErrorData) {
            this.errorState = (ErrorData) sd;
        } else if (sd instanceof NavigationData) {
            this.navigtionState = (NavigationData) sd;
        } else if (sd instanceof VideoCaptureStateData) {
            this.videoState = (VideoCaptureStateData) sd;
        }
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
